<!DOCTYPE html>
<html lang="zxx">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<link rel="icon" href="images/favicon.png">
	<title></title>

	<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
	<link rel="stylesheet" href="css/materialize.css">
	<link rel="stylesheet" href="css/loaders.css">
	<link rel="stylesheet" href="css/lightbox.css">
	<link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css">
	<link rel="stylesheet" href="css/owl.carousel.min.css">
	<link rel="stylesheet" href="css/owl.theme.default.min.css">
	<link rel="stylesheet" href="css/style.css">
	    <link rel="stylesheet" href="css/layer.css">

</head>
<style>

</style>
<body>
	
	<!-- navbar -->
	<div class="navbar">
		<div class="container">
			<div class="row">
				<div class="col s9">
					<div class="content-left" onclick="javascript:history.back('index.html');">
					<i class="fa fa-chevron-left center"></i>
										</div>
				</div>
				
			</div>
		</div>
	</div>
	<!-- end navbar -->
	
	<!-- sidebar -->
	
	<!-- end sidebar -->

	<!-- table -->
<div class="segments-page">
		<div class="container" style=" width: 90%;">
			<div class="pages-title">
				<h3>激活码管理</h3>
				<div class="line"></div>
			</div>
			<div class="total-pay">
				<div class="row">
					<div class="col s8">
						<div class="contents">
							<p>激活码总数</p>
						</div>
					</div>
					<div class="col s4">
						<div class="contents right">
							<p id="notcount"></p>
						</div>
					</div>
					<div class="col s8">
						<div class="contents">
							<p>已使用激活码</p>
						</div>
					</div>
					<div class="col s4">
						<div class="contents right">
							<p id="havecount"></p>
						</div>
					</div>
					<div class="col s8">
						<div class="contents">
							<p>未使用激活码</p>
						</div>
					</div>
					<div class="col s4">
						<div class="contents right">
							<p id="yetcount"></p>
						</div>
					</div>
				
				</div>
			</div>
			
			<div class="checkout">
					<form id="form" onsubmit="return false" action="##" method="post">
					<input type="text" name="Member_account"  placeholder="会员账号">
					<input type="number"min="1" name="number" placeholder="数量">
					<input type="password" name="TradersPassword" placeholder="交易密码">
					<button class="button checkout-button " onclick="delivery();"><i class="fa fa-send"></i>派送</button>
				</form>
			</div>
			
		</div>
	</div>
	<div class="pages-title">
			<h3>赠送流水</h3>
			<div class="line"></div>
			<div class="list_box table-contents z-depth-1" style="min-height: 200px;padding: 0px 10px 0;" >
					<table>
						<thead>
							<tr>
									<th>记录</th>
									
									<th>时间</th>
							</tr>
							
						</thead>
						<tbody id="container">
						</tbody>
					</table>
		</div>
	</div>
	<!-- end table -->
	<script src="js/jquery.min.js"></script>
	<script src="js/materialize.js"></script>
	<script src="js/owl.carousel.min.js"></script>
	<script src="js/main.js"></script>
	<script src="js/jquery.min.js"></script>
	<script src="js/materialize.js"></script>
	<script src="js/numscroller.js"></script>
	<script src="js/lightbox.js"></script>
	<script src="js/owl.carousel.min.js"></script>
	<script src="js/main.js"></script>
	<script src="js/layer.js"></script>
	<script src="js/jquerysession.js"></script>
	<script src="http://www.gongjuji.net/Content/files/jquery.md5.js"></script>
	<script src="js/index.js"></script>
<script>

	$(document).ready(function () {
	    var GetActivationurl = 'Member/GetActivation';
	    var GetActivationInfo = api_request(GetActivationurl, 'GET');
	    if(GetActivationInfo.code==1){
			var havecount=GetActivationInfo.data.havecount; //查询当前会员已经使用的激活码
			var notcount=GetActivationInfo.data.notcount; //查询当前会员所有的激活码
			var yetcount=notcount-havecount;
			
			var havecounthtml = document.getElementById("havecount");
			havecounthtml.innerHTML += havecount;
			
			var notcounthtml = document.getElementById("notcount");
			notcounthtml.innerHTML += notcount;
			var yetcounthtml = document.getElementById("yetcount");
			yetcounthtml.innerHTML += yetcount;
			
			var Billurl = 'Bill/Bill?type=4,5&genre=4';
			
				var BillInfo = api_request(Billurl, 'GET');
				var data=BillInfo.data
				if(data){
					var html = "";
					for(var i=0;i<data.length;i++){
						 var ls=data[i];
						html="<tr><td>"+ls.details+"</td><td>"+ls.add_time+"</td></tr>"
						   $('#container').append(html);
					}
				}else{
					html="暂未派送"
					var container = document.getElementById("container");
					container.innerHTML += html;
				}
				
			}

	 }); 
	 function delivery(){
		   var params = $('#form').serializeObject();
		   if(!params.Member_account){
			   layer.open({
			       content: '请输入下级会员账号!'
			       , skin: 'msg'
			       , time: 2 //2秒后自动关闭
			   });
			   return false;
		   }
		   if(!params.number){
		   			   layer.open({
		   			       content: '请输入派送数量!'
		   			       , skin: 'msg'
		   			       , time: 2 //2秒后自动关闭
		   			   });
		   			   return false;
		   }
		   if(!params.TradersPassword){
		   			   layer.open({
		   			       content: '请输入交易密码!'
		   			       , skin: 'msg'
		   			       , time: 2 //2秒后自动关闭
		   			   });
		   	  return false;
		   }
		   layer.open({
		     content:"确定派送吗?"
		     ,btn: ['确定', '取消']
		     ,yes: function(index){
		       var deliveryurl = 'Member/delivery';
		   					  var deliveryInfo = api_request(deliveryurl, 'POST',params);
							
		   					  if(deliveryInfo.code==1){
		   						layer.open({
		   						    content: deliveryInfo.data
		   						    , skin: 'msg'
		   						    , time: 2//2秒后自动关闭
		   						    , end: function () {
		   								   location.reload();
		   						    }
		   						});
		   					  }
		     }
		   });
	
	 }

</script>
</body>
</html>